----------------------------------Spell Variables--------------------------------------
SPELL.m_iSpellID = 7332 -- Whatever value you want as long as it doesn't override any other spells' IDs.
SPELL.m_iRange = 1024
SPELL.m_sName = "Shield Barrier"
SPELL.m_sToolTip = [[Raise your shield, reducing
					all incoming damage by 50% for
					8 seconds.]]
SPELL.m_sIcon = "devin/blackbetty/spells/warrior/shieldbarrier.jpg"
SPELL.m_iCoolDown = 15
SPELL.m_iManaCost = 0
SPELL.m_bRequiresTarget = false
SPELL.m_iSpellType = SPELLTYPE_SHIELDDEFENSIVE
SPELL.shieldon = false
SPELL.m_bRecastWhileCasting = false

---------------------------------------------------------------------------------------

function SPELL:Cast( pl, target )
	
	pl:EmitSound("devin/blackbetty/weapons/ShieldWall.wav", 90, 100)
	pl.Speed = true 
	pl.SpeedMod = 0.5
	pl.SpeedModDuration = 8
	pl.SpeedType = "Charge"
	pl.DMGMod = true
	pl.DMGMod_Amount = 0.5
	pl.DMGMod_Duration = 8
	pl.HealIncrease = true
	self.shieldon = true
	local modeleffect = ents.Create("prop_dynamic")
		modeleffect:SetMoveParent(pl:GetWeapon("weapon_all"))
		modeleffect:SetPos(pl:GetPos() + Vector(0, 0, -38))
		modeleffect:SetAngles(pl:GetAngles())
		modeleffect:SetLocalAngles(Angle(0, 0, 0))
		modeleffect:SetModel(Model("models/devin/rpgdm/spellmodels/shield_wall.mdl"))
		modeleffect:DrawShadow( false )
		modeleffect:Spawn()
		modeleffect:Activate()
		modeleffect:SetModelScale( 1.2, 0 );
		local sequence = modeleffect:LookupSequence("idle")
		modeleffect:SetSequence(sequence)
		modeleffect:SetPlaybackRate(1.0)
		
	timer.Simple(8, function() modeleffect:Remove() pl.HealIncrease = false self.shieldon = false end)
	
	timer.Simple(0.2, function()
		pl:SetNWBool("Casting", false) 
		pl:SetNWBool("Casted", false)
	end)

end

if CLIENT then
	local function ShieldWallForceCrouch(pl, cmd)
		if(self.shieldon)then
			cmd:SetButtons( cmd:GetButtons() || IN_DUCK )
		end
	end
	hook.Add( "PlayerTick", "ShieldWallForceCrouch", ShieldWallForceCrouch)
end





